package cn.itcast.service.impl;

import cn.itcast.dao.cargo.ShippingDao;
import cn.itcast.domain.cargo.Packing;
import cn.itcast.domain.cargo.Shipping;
import cn.itcast.domain.cargo.ShippingExample;
import cn.itcast.service.ShippingService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ShippingServiceImpl implements ShippingService {
    @Autowired
    private ShippingDao shippingDao;
    @Override
    public PageInfo findAll(ShippingExample shippingExample, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Shipping> packings = shippingDao.selectByExample(shippingExample);
        PageInfo pb = new PageInfo<>(packings);
        return pb;
    }

    @Override
    public Shipping findById(String id) {
        Shipping shipping = shippingDao.selectByPrimaryKey(id);
        return shipping;
    }

    @Override
    public void delete(String id) {
        shippingDao.deleteByPrimaryKey(id);
    }

    @Override
    public void save(Shipping shipping) {
        shippingDao.insert(shipping);
    }


}
